package com.ls.cloud.entity;

import com.ls.cloud.business.common.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @author: candy33
 * @Date: 2022/05/12 0:43
 * com.ls.cloud.entity
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@SQLDelete(sql = "UPDATE system_user SET deleted = 1 WHERE id = ? ")
@SQLDeleteAll(sql = "UPDATE system_user SET deleted = 1 WHERE id = ? ")
@Table(name = "system_user")
@Where(clause = "deleted = 0")
//@EntityListeners(DataBaseAuditListener.class)
public class SystemUser extends BaseEntity implements Serializable {

    @Id
    private Integer id;

    @Column(name = "username",unique = true, nullable = false, columnDefinition = "varchar(50) comment '用户登录名'")
    private String username;

    @Column(name = "password", nullable = false, columnDefinition = "varchar(100) comment '用户密码'")
    private String password;

    @Column(name = "real_name", nullable = false, columnDefinition = "varchar(32) comment '用户名称'")
    private String realName;

    @Column(name = "admin", nullable = false, columnDefinition = "tinyint(1) default 0 comment '是否最高管理员'")
    private Boolean admin;

    @Column(name = "email", columnDefinition = "varchar(100) default '' comment '用户邮箱地址'")
    private String email;

    @Column(name = "phone", columnDefinition = "varchar(30) default '' comment '用户手机号码'")
    private String phone;

    @Column(name = "avatar", columnDefinition = "varchar(255) default '' comment '用户头像地址'")
    private String avatar;

    @Column(name = "sex", columnDefinition = "int(1) default 0 comment '用户性别：0：未知、1：男、2：女'")
    private Integer sex;

    @Column(name = "user_lock", nullable = false, columnDefinition = "int(1) default 0 comment '用户锁定状态'")
    private Integer userLock;

    @Column(name = "login_ip", columnDefinition = "varchar(15) default '' comment '用户登录的IP地址'")
    private String loginIp;

    @Column(name = "login_date", columnDefinition = "datetime comment '用户登录的时间'")
    private Date loginDate;

    @Column(name = "last_login_ip", columnDefinition = "varchar(15) default '' comment '用户上次登录的IP地址'")
    private String lastLoginIp;

    @Column(name = "last_login_date", columnDefinition = "datetime comment '用户上次登录的时间'")
    private Date lastLoginDate;

    @Column(name = "user_status", nullable = false, columnDefinition = "int(2) default 1 comment '用户状态'")
    private Integer userStatus;

    @Column(name = "tissue_id", columnDefinition = "int(11) comment '用户所属组织ID（暂未使用）'")
    private Integer tissueId;
}
